package example.org;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

import android.os.Environment;

public class Resource {
	public static boolean isFirstStart = false;
	public static boolean isServiceRun = false;
	public static boolean isSoundActive = false;
	public static boolean status = false;

	public static String savePath = Environment.getExternalStorageDirectory()
			+ "/ScreenShooter";

	// Write File
	public static void WriteSetting() {
		try {
			File file = new File(savePath + "/check.txt");
			file.createNewFile();
			FileOutputStream fos = new FileOutputStream(file);
			OutputStreamWriter ousWriter = new OutputStreamWriter(fos);
			ousWriter.write(isSoundActive + "");
			ousWriter.flush();
			ousWriter.close();
			fos.close();
		} catch (Exception e) {

		}
	}

	// Read File
	public static boolean ReadSetting() {
		boolean hasil = false;

		try {
			File file = new File(savePath + "/check.txt");
			
			if (file.exists()) {
				FileInputStream fis = new FileInputStream(file);
				BufferedReader buffReader = new BufferedReader(new InputStreamReader(fis));
				hasil = Boolean.parseBoolean(buffReader.readLine());
			} else {
				WriteSetting();
				hasil = Resource.isSoundActive;
			}
		} catch (Exception e) {

		}

		return hasil;
	}
}
